package com.baidu.process.utils;

import org.springframework.stereotype.Component;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Random;

@Component
public class DefaultUtils {

    public String getTranId(String  robotHashCode) {

        DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
        String yyyyMMddhhmmss = dtf.format(LocalDateTime.now());

        Random rand = new Random();
        String  NNN="";
        int c=(rand.nextInt(999)+1);
        if (c<10){
            NNN="00"+c;
        }else if (c<100){
            NNN="0"+c;
        }else {
            NNN=c+"";
        }

        String TranId="AI"+robotHashCode+yyyyMMddhhmmss+NNN;
        return  TranId;
    }

    public String getTodayDateTime(){
        DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
        String yyyyMMddhhmmss = dtf.format(LocalDateTime.now());
        return yyyyMMddhhmmss;
    }

    public String getTodayDate(){
        DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyyMMdd");
        String yyyyMMdd = dtf.format(LocalDateTime.now());
        return yyyyMMdd;
    }


}
